{extend name='admin@public/content'}

{block name="content"}
<form autocomplete="off" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='form-horizontal layui-form padding-top-20'>

    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <!--<ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
        </ul>-->
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="form-group">
                    <label class="col-sm-2 control-label">标题</label>
                    <div class='col-sm-8'>
                        <input autofocus name="title" value="{$vo.title}" title="请输入标题" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">抢单结束时间</label>
                    <div class='col-sm-8'>
                        <input readonly name="endtime" value="{$vo.endtime|date='Y-m-d H:i:s'}" title="请选择抢单结束时间" placeholder="请选择结束时间" class="layui-input js_time_box">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">详细地址</label>
                    <div class='col-sm-8'>
                        <input value="{$vo.address|default=''}" class="layui-input" name="address"/>
                        <input type="hidden" name="lng" value="{$vo.lng|default=''}"/>
                        <input type="hidden" name="lat" value="{$vo.lat|default=''}"/>
                        <a href="javascript:;" class="js_map_btn">地图</a>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-required">图片</label>
                    <div class='col-sm-8'>
                        <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                            <thead>
                            <tr>
                                <td>图片</td>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="text-top">
                                    <input type="hidden" name="images" value="{$vo.images|default=''}">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <script>
                            $('input[name="images"]').uploadMultipleImage();
                        </script>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">是否推送微信消息</label>
                    <div class='col-sm-8'>
                        <label class="think-checkbox"><input lay-ignore class="list-check-box"  type="checkbox" value="1" name="is_notice"/> 推送</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">推送分类</label>
                    <div class='col-sm-4'>
                        <select name="type" required="required" lay-filter="type">
                            <option value="32" {$vo['type']==32?'selected':''}>找厂家</option>
                            <option value="33" {$vo['type']==33?'selected':''}>找人</option>
                        </select>
                    </div>
                    <div class='col-sm-4'>
                        <select name="extend_type" lay-filter="extend_type">
                            <option value="0">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">联系电话</label>
                    <div class='col-sm-8'>
                        <input name="mobile" value="{$vo.mobile}" title="请输入联系电话" placeholder="请输入联系电话" class="layui-input">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">最低参与信用分</label>
                    <div class='col-sm-8'>
                        <input name="min_credit" value="{$vo.min_credit}" title="请输入最低信用分" placeholder="请输入最低信用分" class="layui-input">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">抢单价格</label>
                    <div class='col-sm-8'>
                        <input name="price" value="{$vo.price}" title="请输入抢单价格" placeholder="请输入抢单价格" class="layui-input">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态</label>
                    <div class='col-sm-8'>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['status']=='-1'?'checked':''} value="-1" name="status"/> 已关闭</label>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['status']=='0'?'checked':''} value="0" name="status"/> 待审核</label>
                        <label class="think-radio"><input lay-ignore type="radio" {$vo['status']=='1'?'checked':''} value="1" name="status"/> 已审核</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-required">详细描述</label>
                    <div class='col-sm-8'>
                        <textarea name="content">{$vo.content|default=''|htmlspecialchars_decode}</textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="col-sm-7 col-sm-offset-2">
        <div class="layui-form-item text-center">
            {if !empty($vo.id)}
            <input type="hidden" name="id" value="{$vo.id}">
            <input type="hidden" name="mid" value="{$vo.mid}">
            {/if}
            <button class="layui-btn" type="submit">保存</button>
            <button class="layui-btn layui-btn-danger" type='button' onclick="window.history.back()">取消</button>
        </div>
    </div>

    <style>
        .background-item {
            padding: 15px;
            background: #efefef;
        }
        .no_border{border:none;}
        .background-item thead tr {
            background: #e0e0e0
        }
        .w30{width: 30%;float: left;}
        .js_map_btn{position: absolute;right: 25px;top: 7px;text-decoration: none;}
    </style>
    <script>
        $(function(){
            $('.js_map_btn').click(function () {
                layer.open({
                    type: 2,
                    area: ['700px', '400px'],
                    fixed: false, //不固定
                    maxmin: false,
                    content: '{:url("member/choose_position")}?address='+$('input[name=address]').val()
                });
            });
            choose_extend_type();
            form.on('select(type)', function(){
                $('select[name=extend_type]').html('');
                choose_extend_type();
            });
        });
        function choose_extend_type(){
            var type=$('select[name=type]').val();
            var cur_extend_type="{$vo['extend_type']}";
            $.get("/api/other.system/my_cate_list",{pid:type} ,function(result,status){
                if(status!='success')return;
                var _html='';
                $.each(result.data,function(index,obj){
                    if(obj.id==cur_extend_type){
                        _html+='<option selected value="'+obj.id+'">'+obj.title+'</option>';
                    }else{
                        _html+='<option value="'+obj.id+'">'+obj.title+'</option>';
                    }
                });
                $('select[name=extend_type]').html(_html);
                window.form.render();
            });
        }
        require(['jquery', 'ckeditor', 'angular'], function () {
            window.form.render();
            window.createEditor('[name="content"]', {height: 300});
        });
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: 'input.js_time_box',
                btns: ['now', 'confirm'],
                type:'datetime'
            });
        });
    </script>
</form>
{/block}